package vns.client.presenter;

import vns.client.VNSmartUI;
import vns.client.service.RuleSetServiceAsync;
import vns.client.view.RuleSetDetailUI;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;

public class RuleSetDetailPresenter implements Presenter{

	@Override
	public void go(HasWidgets container) {
		container.clear();
		container.add(display.asWidget());
		doInit();
	}

	public interface Display{
		Button getUpdateButton();
		Button getCalcelButton();
		Widget asWidget();
		void render();
	}

	private final Display display;
	private final SimpleEventBus eventBus;
	private final RuleSetServiceAsync rpcService;
	
	/*
	 * Public method
	 */
	
	public RuleSetDetailPresenter(RuleSetDetailUI view, SimpleEventBus eventBus, RuleSetServiceAsync model){
		this.display = view;
		this.eventBus = eventBus;
		this.rpcService= model;
		bind();
	}
	
	/*
	 * Private method
	 */
	
	private boolean bind(){
		display.getUpdateButton().addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				doUpdate();
			}
		});
		display.getCalcelButton().addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				VNSmartUI.get().callLastToken();
			}
		});
		return false;
	}

	private void doInit() {

	}

	private void doUpdate(){

	}
}
